package method;

public class T5 {
    // public static Thread currentThread() 获取当前线程对象
    public static void main(String[] args) {
//        创建线程任务资源
        MyRunnable myRunnable = new MyRunnable();
//        创建线程对象 将资源传入
        Thread thread = new Thread(myRunnable,"A: ");//从这里设置线程名
        thread.start();
        for (int i = 0; i < 500; i++) {
            System.out.println(Thread.currentThread().getName()+"主线程");
        }
    }
}
class MyRunnable implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 500; i++) {
//          这是 实现接口时 获取线程名的方法
            System.out.println(Thread.currentThread().getName()+"线程");
        }
    }
}
